//10.4 - File Copier - Dirk Henkemans - Prima Publishing #include #include using namespace std; int main( void ) { char buffer; int index = 0; //the file names const char filename1[] = "dragons.txt"; const char filename2[] = "dragons2.txt"; //opening the files fstream file1(filename1, ios::in); fstream file2(filename2, ios::out); //points to the beginning of the files file1.seekg(0, ios::beg); file2.seekp(0, ios::beg); //reads the first char file1.read(&buffer, 1); //writes the remainder of the chars while(file1.good() && file2.good()) { file2.write(&buffer, 1); index++; file1.seekp(index); file2.seekg(index); file1.read(&buffer, 1); } //closes the files file1.close(); file2.close(); return 0; }